import { get, post, put, dele } from "../utils/request";

export const getAddresslistApi = (per = 10, page = 1) =>
  get("/api/v1/addresses", { per: per, page: page });

export const addAddressApi = (data) =>
  post("/api/v1/addresses", {
    receiver: data.name,
    mobile: data.tel,
    regions: data.province + "-" + data.city + "-" + data.county,
    address: data.addressDetail,
    isDefault: data.isDefault,
  });

export const updateAddressApi = (id, data) =>
  put("/api/v1/addresses/" + id, {
    receiver: data.name,
    mobile: data.tel,
    regions:
      data.regions || data.province + "-" + data.city + "-" + data.county,
    address: data.addressDetail,
    isDefault: data.isDefault,
  });

export const getAddrApi = (id) => get("/api/v1/addresses/" + id);

export const deleAddrApi = (id) => dele("/api/v1/addresses/" + id);
